package com.taobao.ui.widget;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import com.swtdesigner.SWTResourceManager;
import com.taobao.action.ManagerAction;
import com.taobao.pojo.Config;
import com.taobao.tools.GIF;

public class StatusWidget extends CommonWidget {
    public static final String ID = "com.taobao.ui.widget.StatusWidget";
    private Label versionLabel;
    private Label label;
    private Label label_4;
    private Label label_6;
    private Label label_9;
    private Label label_10;
    private Label label_12;

    private ManagerAction managerAction = new ManagerAction();

    @Override
    public String getID() {
        return StatusWidget.ID;
    }

    /**
     * Create the composite.
     * 
     * @param parent
     * @param style
     */
    public StatusWidget(Composite parent, int style) {
        super(parent, style);
        GridLayout gridLayout = new GridLayout(14, false);
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;
        setLayout(gridLayout);

        label_12 = new Label(this, SWT.NONE);
        GridData gridData_10 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_10.heightHint = 10;
        gridData_10.widthHint = 136;
        label_12.setLayoutData(gridData_10);
        label_12.setVisible(false);
        new GIF().gif(label_12, getShell(), "query.gif");

        label = new Label(this, SWT.NONE);
        GridData gridData_5 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_5.heightHint = 14;
        gridData_5.widthHint = 14;
        label.setLayoutData(gridData_5);
        label.setBackgroundImage(SWTResourceManager.getImageForPath("working.png"));

        Label label_1 = new Label(this, SWT.NONE);
        GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData.widthHint = 62;
        label_1.setLayoutData(gridData);
        label_1.setText("\u7528\u6237\u4FE1\u606F");

        label_4 = new Label(this, SWT.NONE);
        GridData gridData_6 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_6.heightHint = 14;
        gridData_6.widthHint = 14;
        label_4.setLayoutData(gridData_6);
        label_4.setBackgroundImage(SWTResourceManager.getImageForPath("working.png"));

        Label label_5 = new Label(this, SWT.NONE);
        GridData gridData_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_1.widthHint = 62;
        label_5.setLayoutData(gridData_1);
        label_5.setText("\u5927\u5385\u4EFB\u52A1");

        label_6 = new Label(this, SWT.NONE);
        GridData gridData_7 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_7.heightHint = 14;
        gridData_7.widthHint = 14;
        label_6.setLayoutData(gridData_7);
        label_6.setBackgroundImage(SWTResourceManager.getImageForPath("working.png"));

        Label label_7 = new Label(this, SWT.NONE);
        GridData gridData_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_2.widthHint = 52;
        label_7.setLayoutData(gridData_2);
        label_7.setText("\u63A5\u624B\u65B9");

        label_9 = new Label(this, SWT.NONE);
        GridData gridData_8 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_8.heightHint = 14;
        gridData_8.widthHint = 14;
        label_9.setLayoutData(gridData_8);
        label_9.setBackgroundImage(SWTResourceManager.getImageForPath("working.png"));

        Label label_8 = new Label(this, SWT.NONE);
        GridData gridData_3 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_3.widthHint = 52;
        label_8.setLayoutData(gridData_3);
        label_8.setText("\u53D1\u5E03\u65B9");

        label_10 = new Label(this, SWT.NONE);
        GridData gridData_9 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_9.heightHint = 14;
        gridData_9.widthHint = 14;
        label_10.setLayoutData(gridData_9);
        label_10.setBackgroundImage(SWTResourceManager.getImageForPath("working.png"));

        Label label_11 = new Label(this, SWT.NONE);
        GridData gridData_4 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gridData_4.widthHint = 70;
        label_11.setLayoutData(gridData_4);
        label_11.setText("\u5DF2\u5B8C\u6210\u4EFB\u52A1");

        Label label_2 = new Label(this, SWT.NONE);
        label_2.setText("\u7248\u672C\u53F7\uFF1A");

        versionLabel = new Label(this, SWT.NONE);
        versionLabel.setText(Config.version);

        Label label_3 = new Label(this, SWT.NONE);
        label_3.setText("         ");

        managerAction.doAction(getThis(StatusWidget.class));
    }

    public Label getUserInfo() {
        return label;
    }

    public Label getRoomTask() {
        return label_4;
    }

    public Label getReceive() {
        return label_6;
    }

    public Label getPublish() {
        return label_9;
    }

    public Label getHistoryTask() {
        return label_10;
    }

    public Label getQuery() {
        return label_12;
    }

    public void working(Label label) {
        label.setBackgroundImage(SWTResourceManager.getImageForPath("working.png"));
    }

    public void workend(Label label) {
        label.setBackgroundImage(SWTResourceManager.getImageForPath("workend.png"));
    }

    public void workPause(Label label) {
        label.setBackgroundImage(SWTResourceManager.getImageForPath("workpause.png"));
    }

    public void workInfo(Label label) {
        label.setBackgroundImage(SWTResourceManager.getImageForPath("workinfo.png"));
    }

    public void showOrHide(boolean visible) {
        getQuery().setVisible(visible);
    }
}
